package org.example.ioc.pro8_init_destroy;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component   //单例 非懒加载  容器启动时创建对象  容器关闭时销毁对象
public class ConnectionPool {
    public ConnectionPool(){
        System.out.println("ConnectionPool 构造器");
    }
    @PostConstruct  //在构造器之后执行
    public void init(){
        System.out.println("ConnectionPool 初始化");
    }
    @PreDestroy  //在容器销毁之前执行
    public void destroy(){
        System.out.println("ConnectionPool 销毁");
    }
}
